Repository navigation
Conversation
…dences Schedule computes flow and anti dependences before any iteration direction is known, that is as if the loop ran Forward. A backward recurrence, such as `u[t-1] = f(u[t], u[t+1])`, then shows anti dependences, and a Cluster updating `u[t]` before it adds flow dependences. When the iteration Dimension has sub-iterators, the Clusters cannot be scheduled over different IterationSpaces (devitocodes#3008), but the ambiguity is still resolved by forcing Forward, so a backward Operator runs forward (devitocodes#2780). In that case, infer the direction from the dependences of each Cluster on itself instead: Forward if its carried self-dependences are all flow dependences, Backward if they are all anti dependences. Reductions and Clusters without carried self-dependences impose no direction. If a Cluster has both, or the Clusters disagree, the previous rule applies.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the buffered case of #2780, following the discussion there.
Problem
Schedule.callbackcomputesscope.d_flowandscope.d_antiwhile the Clusters still have directionAny, so the distances are those of aForwardloop. Consider an adjoint-like Operator:Read as a forward loop, these Clusters carry both flow and anti dependences along
time. Since #3008, a time loop with sub-iterators is no longer split in this situation, but the ambiguity is still resolved byso the whole Operator runs forward, although it steps
u.backward. Onmain, the #2780 example then givessum(g)5.137421e7 instead of 2.624460e7.Change
When
maybe_breakholds and the loop cannot be split (sub-iterators), the direction is inferred from the dependences of each Cluster on itself (Schedule._recurrence_direction):Scope(c.exprs)and keep the dependences carried bydim, excluding reductions (is_carried(dim) and not is_reduce(dim)).Forward, e.g.u[t+1] = f(u[t]). If they are all anti dependences (d_anti_logical), it requiresBackward, e.g.u[t-1] = f(u[t]). A Cluster without carried self-dependences requires nothing.For the example above, only the stencil Cluster requires a direction (
Backward: 0 carried flow, 6 carried anti dependences). The injection and theInc(a reduction) require none. Intest_no_time_fission_reversing_war, both Clusters requireForward, so its behaviour is unchanged. Nothing in the analysis refers totimespecifically; the fission decision is not changed.Tests
TestLoopScheduling::test_no_time_fission_backward_recurrence: checks for a singleBackwardtime loop and compares against a NumPy reference computed one time step at a time. It fails onmainand passes with this change.TestLoopSchedulingtests pass, including those added in compiler: prevent schedule from breaking loop over subiterators #3008.sum(g)2.624460e7, equal to running the Operator one time step per call.ConditionalDimension-saved forward field and twoIncs (5 variants): all equal to one-time-step-per-call execution;maingives NaN for the 2 variants that readu.backwardafter the stencil.-m "not parallel", without the GPU and MPI test files): 3881 passed. The twotest_dse.py::TestAliases::test_blocking_optionscases fail in our environment, with and without this change.Open question: full storage
With
usaved in full (save=nt) there are no sub-iterators, soSchedulestill splits the loop and theIncreadsu[t-1]after the update at stept-1:sum(g)2.624523e7. With buffering, it reads the value before that update: 2.624460e7, which is also what one-time-step-per-call execution gives with either storage. So the same equations currently give different results depending on storage. This PR does not change the fission decision. Which semantics is intended for a slot written by two equations at different steps? Depending on the answer, the full-storage case could be addressed in the same dependence analysis, either by not splitting or by raising an error where a split changes the result.🤖 Generated with Claude Code